/*************************************
  *epoll event handler 
  *
  *created by dirkcai
  ************************************/
#ifndef EPOLLEVENTHANDLER_H
#define EPOLLEVENTHANDLER_H

#include <sys/types.h>
#include <sys/epoll.h>
#include <fcntl.h>

#include "processor.h"
#include "epollmanager.h"

static int SetNonBlock(int sockfd)  
{  
	if (fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFD, 0)|O_NONBLOCK) == -1)  
	{  
		return -1;  
	}  
	return 0;  
}
class EpollEventHandler
{

public:
	EpollEventHandler( EpollManager * ptEpollEventMng, Processor * ptProcessor );
	virtual ~EpollEventHandler();
	virtual int Handle( epoll_event * ptEvent );

protected:
	virtual int OnAccept( epoll_event * ptEvent ) = 0;	
	virtual int OnRead( epoll_event * ptEvent ) = 0;
	virtual int OnWrite( epoll_event * ptEvent ) = 0;

protected:
	EpollManager * m_ptEpollEventMng;
	Processor * m_ptProcessor;
};

#endif




